attribute vec4 VertexPosition;
#ifdef VS_TEXCOORD0
	attribute vec2 VertexTexCoord0;
#endif

#ifdef VS_TEXCOORD1
	attribute vec2 VertexTexCoord1;
#endif

#ifdef VS_NORMAL
	attribute vec3 VertexNormal
	#ifdef VS_TANGENT_BINORMAL
		attribute vec3 VertexTangent;
		attribute vec3 VertexBinormal;
	#endif
#endif

#if defined(VS_TEXCOORD0) && defined(VS_TEXCOORD1)
	varying vec4 VertexTexCoordVS;
#else
	#if defined(VS_TEXCOORD0) || defined(VS_TEXCOORD1)
		varying vec2 VertexTexCoordVS;
	#endif
#endif

#ifdef VS_VIEWSPACEPOSITION
	varying vec3 VertexPositionVS;
#endif

#ifdef VS_NORMAL
	varying vec3 VertexNormalVS;
	#ifdef VS_TANGENT_BINORMAL
		varying vec3 VertexTangentVS;
		varying vec3 VertexBinormalVS;
		#ifdef VS_PARALLAXMAPPING
			varying vec3 EyeVecVS;
		#endif
	#endif
#endif

#if defined(VS_NORMAL) && defined(VS_TWOSIDEDLIGHTING)
	uniform float NormalScale;
#endif

#if defined(VS_VIEWSPACEPOSITION) || defined(VS_NORMAL)
	uniform mat4 ObjectSpaceToViewSpaceMatrix;
#endif

uniform mat4 ObjectSpaceToClipSpaceMatrix;

#if defined(VS_NORMAL) || defined(VS_TANGENT_BINORMAL)
	uniform vec3 EyePos;
#endif

void main()
{
	gl_Position = ObjectSpaceToClipSpaceMatrix * VertexPosition;
	
#ifdef VS_TEXCOORD0
	#ifdef VS_TEXCOORD1
		VertexTexCoordVS = vec4(VertexTexCoord0, VertexTexCoord1);
	#else
		VertexTexCoordVS = VertexTexCoord0;
	#endif
	
#else
	#ifdef VS_TEXCOORD1
		VertexTexCoordVS = VertexTexCoord1;
	#endif
#endif

#ifdef VS_VIEWSPACEPOSITION
	vec4 viewSpacePosition = ObjectSpaceToViewSpaceMatrix * VertexPosition;
	VertexPositionVS = viewSpacePosition.xyz;
#endif

#ifdef VS_NORMAL
	VertexNormalVS = mat3(ObjectSpaceToViewSpaceMatrix) * VertexNormal;
	#ifdef VS_TWOSIDEDLIGHTING
		VertexNormalVS *= NormalScale;
	#endif
	
	#ifdef VS_TANGENT_BINORMAL
		VertexTangentVS = mat3(ObjectSpaceToViewSpaceMatrix) * VertexTangent;
		VertexBinormalVS = mat3(ObjectSpaceToViewSpaceMatrix) * VertexBinormal;
		
		#ifdef VS_PARALLAXMAPPING
			EyeVecVS = mat3(VertexTangent, VertexBinormal, VertexNormal) * (EyePos - VertexPosition.xyz);
		#endif
	#endif
#endif
}

